package L1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.util.ArrayList;
import java.util.List;

public class _079 {
    /**
     * 天梯赛的善良
     */
    public static void main(String[] args) throws IOException {
        StreamTokenizer st = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
        st.nextToken();
        int N = (int)st.nval;
        int min = Integer.MAX_VALUE;
        int max = Integer.MIN_VALUE;
        int min_num = 0;
        int max_num = 0;
        List<Integer> list = new ArrayList<>();
        for (int i=0;i<N;i++){
            st.nextToken();
            int temp =(int)st.nval;
            list.add(temp);
            if (temp>=max){
                max= temp;
            }
            if (temp<=min){
                min = temp;
            }
        }
        for (int i=0;i<N;i++){
            Integer temp = list.get(i);
            if (temp==min){
                min_num++;
            }
            if (temp==max){
                max_num++;
            }
        }
        System.out.println(min+" "+min_num);
        System.out.println(max+" "+max_num);
    }
}
